

cc.Class({
    extends: cc.Component,

    properties: {
       daggerPrefab:{
         default:null,
         type:cc.Prefab,
       }
    },

   
    onLoad () {
        this.dagger = null;
        this.daggerNode = cc.instantiate(this.daggerPrefab);
        this.enemy = this.node.parent.getComponent('enemy');
       // this.hp = this.enemy.hp;
    },

    show(){
        this.dagger.active = true;
    },
    hide(){
        this.dagger.active = false;
    },

    //碰撞回调
    onCollisionEnter:function(other, self){
       // console.log(self);
        if (other.node.group == 'role' && other.tag == 1) {
            this.enemy.isHurt();
            return;
        }
        if (other.node.group == 'dagger' && other.tag == 2) {
            if (this.dagger) {
                this.enemy.isHurt();
                this.hide();
                this.dagger.removeFromParent();
            }else {
                console.log("找不到该节点");
            }
        }

    },
    update(dt){
        this.dagger = cc.find("Canvas/dagMain");
        // this.degger = this.dagger;
       
    }

});
